/*
 * Register8Bit.java
 *
 * Created on March 19, 2007, 11:20 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package moto9s12sim;

/**
 *
 * @author Fergus Earnshaw
 */
public class Register8bt extends Register{
    
    /** Creates a new instance of Register8Bit */
    private byte bValue;
    
    public Register8bt() {
        
        bValue = 0;
    }
    
    public void setRegister(byte bTmp)
    {
        this.bValue = bTmp;
    }
    
    public byte getRegister()
    {
        return this.bValue;
    }
    
    public void inc()
    {
        this.bValue++;
    }
    
    public void dec()
    {
        this.bValue--;
    }
    
    public String getHex()
    {
        String strTmp;
        
        strTmp = Integer.toHexString((this.bValue >= 0) ? this.bValue : 256 + this.bValue).toUpperCase();
        
        if(strTmp.length() < 2)
        {
            strTmp = "0" + strTmp;
        }
        
        return strTmp;
    }
    
    public int getUnsignedRegister()
    {
       int iTmp;      
       
       if(this.bValue < 0)
       {
           iTmp = (int)(this.bValue)+(256);

       }
       else
       {
           iTmp = (int)this.bValue;
       }
       
       return iTmp;
    }
}
